<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <link rel="icon" type="image/png" sizes="16x16" href="{{ asset('plugins/images/favicon.png') }}">
    <title>后台登陆</title>
    @include('static.css')
</head>

<body>
<!-- Preloader -->
<div class="preloader">
    <svg class="circular" viewBox="25 25 50 50">
        <circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10"/>
    </svg>
</div>
<section id="wrapper" class="login-register">
    <div class="login-box">
        <div class="white-box">
            <form class="form-horizontal form-material" id="loginform" method="post">
                <h3 class="box-title m-b-20">登录</h3>
                <div class="form-group ">
                    <div class="col-xs-12">
                        <input class="form-control" type="text" required id="name" name="name" placeholder="用户名"
                               value="{{old('mobile')}}">
                    </div>
                </div>
                <div class="form-group">
                    <div class="input-group">
                        <input type="password" class="form-control" required placeholder="密码" id="password" name="password" value="{{ old('password') }}"/>
                        <span class="input-group-btn">
                        </span>
                    </div>
                </div>
                {{--<div class="form-group">--}}
                    {{--<div class="col-xs-12">--}}
                        {{--<img src="{{ url('/captcha') }}"--}}
                             {{--onclick="src='{{ url('/captcha') }}?r='+Math.random();"--}}
                             {{--class="pull-right"--}}
                             {{--style="border: 1px solid #ddd;"--}}
                        {{--/>--}}
                        {{--<input class="form-control" type="text" required id="captcha" name="captcha" placeholder="图形验证码"--}}
                               {{--style="width: 62%;">--}}
                    {{--</div>--}}
                {{--</div>--}}

                <div class="form-group text-center m-t-20">
                    <div class="col-xs-12">
                        {!! csrf_field() !!}
                        <button class="btn btn-info btn-lg btn-block text-uppercase waves-effect waves-light"
                                type="submit" id="login">登录
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</section>
@include('static.js')
</body>
<script>

    $('#login').click(function (e) {
        e.preventDefault();
        var name = $('#name').val();
        var password = $('#password').val();
        // var captcha = $('#captcha').val();
        if (!name) {
            toasterror('用户名不能为空');
            return false;
        }
        if (!password) {
            toasterror('密码不能为空');
            return false;
        }
        if (password.length < 5) {
            toasterror('密码不正确');
            return false;
        }
        // if (captcha.length < 5) {
        //     toasterror('图形验证码不正确');
        //     return false;
        // }
        $.ajax({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            url: '/login/fgregregrehytInnnIJNBGKNKJ',
            type: 'POST',
            data: {'name': name, 'password': password},
            success: function (data) {
                if (data.status !== 1) {
                    $('img').click();
                    toasterror(data.message);
                } else {
                    window.location.href = '/';
                }
            },
            error: function (e) {
                if (e.readyState === 4 && e.status === 422) {
                    for (var i in e.responseJSON) {
                        if (e.responseJSON[i] !== 'The given data was invalid.') {
                            err = e.responseJSON[i];
                            for (var j in err) {
                                toasterror(err[j][0]);
                            }
                        }
                    }
                }
            }
        })
    });

</script>
</html>
